home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1996 September / JCSM Shareware Collection (JCS Distribution) (September 1996).ISO / bother__ / cenvid.zip / CENVIDOS.ZIP / FLOPPYIN.BAT < prev    next >
DOS Batch File  |  1995-03-31  |  2KB  |  42 lines

  1. @echo off
  2. :: ***************************************************************
  3. :: *** FloppyIn.bat - Check if there is a floppy disk in drive ***
  4. :: *** ver.2          A: or B:, set ERRORLEVEL 1 if there is   ***
  5. :: ***                not, else ERRORLEVEL 0 if there is       ***
  6. :: ***************************************************************
  7.  
  8. :: CHECK FOR VALID A, B, a, or b
  9.    if "%1" == "A" GOTO VALID_DRIVE
  10.    if "%1" == "a" GOTO VALID_DRIVE
  11.    if "%1" == "B" GOTO VALID_DRIVE
  12.    if "%1" == "b" GOTO VALID_DRIVE
  13.    CEnviD printf("USAGE: FloppyIn  < A | a | B | b >\a\n")
  14.    CEnviD printf("       ERRORLEVEL 1 if NO FLOPPY; else ERRORLEVEL 0\n") return(1)
  15.    GOTO FLOPPYIN_EXIT
  16.  
  17. :VALID_DRIVE
  18. :: Try to read a sector 3 times, return 1 if cannot read
  19.    CEnviD "#include '%0,bat,::CODE' IsFloppyIn('%1')"
  20.    IF ERRORLEVEL 1 ECHO NO FLOPPY IN DRIVE
  21.    IF NOT ERRORLEVEL 1 ECHO FLOPPY IS IN DRIVE
  22.    ::Code  IsFloppyIn(Drive)
  23.    ::Code  {
  24.    ::Code     BLObSize(buf,5000)// prepare a big buffer
  25.    ::Code     for ( i = 0; i < 3; i++ ) {
  26.    ::Code        reg.ah = 2           // code for reading sectors
  27.    ::Code        reg.al = 1           // read one sector
  28.    ::Code        reg.ch = 0           // track number
  29.    ::Code        reg.cl = 1           // sector number
  30.    ::Code        reg.dh = 0           // disk side (0 or 1)
  31.    ::Code        reg.dl = toupper(Drive) - 'A'
  32.    ::Code        reg.es = segment(buf) // es:bx point to buffer
  33.    ::Code        reg.bx = offset(buf)
  34.    ::Code        if ( interrupt(0x13,reg,outreg) )
  35.    ::Code         exit(0)  // floppy read OK (carry flag not set)
  36.    ::Code     }
  37.    ::Code     // If finished loop without finding floppy, then error
  38.    ::Code     exit(1)
  39.    ::Code  }
  40.  
  41. :FLOPPYIN_EXIT
  42.